Conversation
KhafraDev
left a comment
There was a problem hiding this comment.
There is no reason to change it
mcollina
left a comment
There was a problem hiding this comment.
This allocates way less promises and I expect to improve performance.
I don't really understand how this work tho. What if part of the body is not available?
|
If body is null or invalid then it would break already in an earlier stage in the function which calls readAllBytes, because we call The only place we can error is when the |
|
LOL, I actually found a bug in the sri code. I was wondering why setting the rejection handler in readLoop is not working. |
|
What about if a large file is transmitted? Is fetch already buffering all of that in memory? |
|
Only if you use one of those methods from the bodyMixing, like For streams you have that logic directly in mainFetch called incrementalReadBody or so. There we use alot of magic like async generators. |
|
Can you bench it somehow? I think it's a pretty good change if there's a significant improvement |
|
What I need is a way to count the generated Promises. |
|
I use https://github.com/bengl/count-promises for that |
|
@Uzlopak this now conflicts. can you use #4349 (comment) to count the promises? @KhafraDev this seems to allocate way less promises than async/await combo. |
e7e6644 to
36cf917
Compare
|
My change reduces according to the "test" that the amount of promises is reduced by 1 per fetch call |
|
1 less promise? |
|
yes, 1 less promise. We create about 50 promises for a fetch call. See the other PRs regarding removing async/promises. Maybe we can remove overall about 10 promises. |
gurgunday
left a comment
There was a problem hiding this comment.
Just my 50c but I think this and other PRs that remove unnecessary promises are ultimately beneficial and they add up
|
@KhafraDev can you take another look? I don't see how this is problematic |
|
This needs a rebase, so that latest tests can run |
Because we cant access the ReadableStreamDefaultReader logic inside node core to provide our own reader with the specified logic as mentioned in the spec. Before readAllBytes is async, which is confusing because we provide two callbacks to it. Now it reads more natural for me.
Status